<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="error" uri="/WEB-INF/tags/ErrorTag.tld"%>

<t:basicTemplate
	pageTitle="SWIMv2 - ${userName}- Incoming Help Requests">

	<jsp:attribute name="extrahead">
		<link rel='stylesheet' href='css/help_request_style.css'
			type='text/css' />
		<script src="WRITE_SCRIPT_NAME_HERE_NOW_WE_DEBUG_IN_PEACE"></script>
	</jsp:attribute>
	
	<jsp:body>
    	<h1> Your requests for help</h1>
    	
    	<!-- error container -->
		<div class="error-style">
				<error:errors error="${param.error}"></error:errors>
		</div>
		
    	<p> Wellcome, ${userName}!</p>
    	<c:if test="${not empty message}">
			<p>${message}</p>	
		</c:if>
		<c:if test="${not empty error}">
			<p>${error}</p>	
		</c:if>
			
		<c:if test="${fn:length(help_requests) > 0}">
			
			<c:forEach items="${help_requests}" var="map_req"> 
					<br /> <br />
					<form name="form" action="./processHelpRequests?utente=ciccio" method="POST"> 	
						<div id="see_help_request">
							
							 Help Request made by: ${map_req['asker'] }  <br/>
							 This day:  ${map_req['creation_date'] }
							
							<details>
						 			 <summary> ${map_req['title']} - Click here to see description </summary>
						  		  	 <p> ${map_req['summary']} </p>
							</details>
						
							
							<input type="radio" name="radio_acceptance" value="Approve">
							Grant Help
							
					    	<input type="radio" name="radio_acceptance"  value="Disapprove">
					    	 Deny Help (shame on you, selfish!)
					    	 
					    	 <input type="hidden" name="help_req_id"
					    	   value="${map_req['id']} @ ${map_req['creation_date']} @ ${map_req['asking']}" />
					    
					    	
						</div> <br /> <br />
						
						<input type="submit" value="Grant help!" name="submit" /> 
					
					</form>
			</c:forEach>
			
			
		</c:if>
		
		<c:if test="${fn:length(help_requests) == 0}">
			<h2> There are no Help Requests </h2>
			<br />
			(deal with it)
		</c:if>
		

    	
    </jsp:body>
</t:basicTemplate>